<?php

declare(strict_types=1);
/**
 * Created by project.
 * User: huanzipap
 * Date: 2023/5/10
 * Time: 11:25
 */
namespace App\Controller;


use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\RequestMapping;
use App\Libs\Wx\WxSdk;


#[Controller(prefix: 'wxTools')]
class WxToolsController extends AppBaseController
{
    #[Inject]
    protected WxSdk $wxSdk;
    /**
     * 微信jssdk功能config信息
     * @return \Psr\Http\Message\ResponseInterface
     */
    #[RequestMapping(path:'config',methods: 'get')]
    public function config(): object
    {
        try{
            $share_page_url = $this->request->input('page_url',null);
    //        $share_page_url = 'https://p1.rp-mall.com/hanglung23/test';
            if($share_page_url==null) return $this->reMsg->re(10006);
            $config = $this->wxSdk->getSignPackage($share_page_url);
            return $this->reMsg->re(1,'success',$config);
        }catch (\Exception $exception){
            return $this->diyError->errorJson($exception);
        }
    }
}
